# _*_ coding:utf-8 _*_
# 开发人员：money666
# 开发时间：2019-08-1617:00
# 文件名:weibo.py

from selenium import webdriver
import time

url = 'https://weibo.com/u/6675603112?is_hot=1'


def start_chrome():
    driver = webdriver.Chrome(executable_path='/Users/shixueyan/PycharmProjects/untitled3_check/chromedriver')
    driver.start_client()
    return driver

def find_info():
    sel = 'strong.W_f18'
    elems = driver.find_elements_by_css_selector(sel)
    return [int(el.text) for el in elems[0:]]

while True:
    driver = start_chrome()
    driver.get(url)
    time.sleep(10)
    info = find_info()
    # [11,22]
    guanzhu,fans,number = info     #关注、粉丝、微博数
    if guanzhu  > 8:
        print(f'珺宝的关注数变成了：'+str(guanzhu))
    else:
        print('珺宝的关注还是8个')
    if fans > 10:
        print (f'珺宝的粉丝数变成了：'+str(fans))
    else:
        print('珺宝的粉丝还是10个')
    if number > 119:
        print (f'珺宝的微博数变成了：'+str(number))
    else:
        print('珺宝的微博还是119条')
    time.sleep(3600)    #一小时看一次

# def find_info() -> object:
#     # css_select
#     sel = 'span>span.line.S_line1>span>em:nth-child(2)'
#     elems = driver.find_elements_by_css_selector(sel)
#     return [int(el.text) for el in elems[3:]]

# while True:
#     driver = start_chrome()
#     driver.get(url)
#     time.sleep(6)
#     info = find_info()
#     # [123,456,789]
#     like = info
#     if like > 30:
#         print('你所关注的微博转发已经过 ' + str(like))
#         print((f'你喜欢的微博超过了{like}'))
#         break
#     else:
#         print('not happening')
#
#         time.sleep(1200)
